package com.xcity.record;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.xcity.merge.MergeUtil;

public class Relation extends BaseRecord {
	public static String SQL_PARA = "id, friends, friendsApply";

	public static String COUNT_SQL = "select count(id) from relation";
	public static String SELECT_LIMIT = "select * from relation limit {0},{1}";
	
	public static final byte[] applys = new byte[]{};
	
	protected long id;
	protected byte[] friends;
	protected byte[] friendsApply;
	
	@Override
	public void load(ResultSet rs) throws SQLException {
		this.id = rs.getLong(1);
		this.friends = rs.getBytes(2);
		this.friendsApply = applys;//rs.getBytes(3);
	}

	@Override
	public String getColumnNames() {
		return SQL_PARA;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(MergeUtil.toSqlString(id));
		sb.append(", ");
		sb.append(MergeUtil.toHexString(friends));
		sb.append(", ");
		sb.append(MergeUtil.toHexString(friendsApply));
		return sb.toString();
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public byte[] getFriends() {
		return friends;
	}

	public void setFriends(byte[] friends) {
		this.friends = friends;
	}

	public byte[] getFriendsApply() {
		return friendsApply;
	}

	public void setFriendsApply(byte[] friendsApply) {
		this.friendsApply = friendsApply;
	}

}
